
package com.sys.web.util;

import com.sys.dao.model.GftUserInfo;
import org.apache.commons.beanutils.PropertyUtils;

import com.sys.base.UserBean;
import com.sys.plat.web.core.ActionContext;
import com.sys.system.Constants;

public class SystemUtil {


	public static UserBean getLoginUser(){
		/*UserBean userBean = (UserBean) ActionContext.getRequest().getSession(true).getAttribute(Constants.USERBEAN);
		if( userBean==null)
			userBean= new UserBean();*/


        UserBean userBean = new UserBean();
        GftUserInfo gui = new GftUserInfo();
        gui.setId("53d89ab12495835701249583666a0001");
        userBean.setGftUserInfo(gui);


		 return userBean;
	}
	
	/**
	 * 
	 * @param source as obj.obj2.attr
	 * @return
	 */
	public static String getSessionValue(String source) {
		String retValue = "";
		String[] args = source.split("\\.");
		if ( 0 < args.length ) {
			retValue = getSessionAttr(args);
		}
		return retValue;
	}
	
	/**
	 * for循环取得session中对象的属�1�7��1�7�1�7
	 * 
	 * @param args
	 * @return
	 */
	private static String getSessionAttr(String[] args) {
		Object obj = ActionContext.getRequest().getSession().getAttribute(args[0]);
		try {
			for ( int i = 1; i < args.length; i++ ) {
				obj = PropertyUtils.getProperty(obj, args[i]);
			}
		} catch (Exception e) {
			return "";
		}
		if ( null == obj )
			obj = "";
		return obj.toString();
	}
}
